using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>

    public class TVC_CATEInfo
    {
        #region Local Variable
        public class Field
        {
            public const string db = "db",
                maingroup = "maingroup",
                mainname = "mainname",
                rowrank = "rowrank",
                subgroup = "subgroup",
                subname = "subname",
                sizecode = "sizecode",
                sizename = "sizename",
                lengthcode = "lengthcode",
                lengthname = "lengthname";
        }
        private String _db;
        private String _maingroup;
        private String _mainname;
        private String _rowrank;
        private String _subgroup;
        private String _subname;
        private String _sizecode;
        private String _sizename;
        private String _lengthcode;
        private String _lengthname;

        public String db { get { return _db; } set { _db = value; } }
        public String maingroup { get { return _maingroup; } set { _maingroup = value; } }
        public String mainname { get { return _mainname; } set { _mainname = value; } }
        public String rowrank { get { return _rowrank; } set { _rowrank = value; } }
        public String subgroup { get { return _subgroup; } set { _subgroup = value; } }
        public String subname { get { return _subname; } set { _subname = value; } }
        public String sizecode { get { return _sizecode; } set { _sizecode = value; } }
        public String sizename { get { return _sizename; } set { _sizename = value; } }
        public String lengthcode { get { return _lengthcode; } set { _lengthcode = value; } }
        public String lengthname { get { return _lengthname; } set { _lengthname = value; } }

        #endregion LocalVariable

        #region Constructor
        public TVC_CATEInfo()
        {
            _db = "";
            _maingroup = "";
            _mainname = "";
            _subgroup = "";
            _subname = "";
            _sizecode = "";
            _sizename = "";
            _lengthcode = "";
            _lengthname = "";
        }
        public TVC_CATEInfo(
        String maingroup,
        String mainname,
        String subgroup,
        String subname,
        String sizecode,
        String sizename,
        String lengthcode,
        String lengthname
        )
        {
            _maingroup = maingroup;
            _mainname = mainname;
            _subgroup = subgroup;
            _subname = subname;
            _sizecode = sizecode;
            _sizename = sizename;
            _lengthcode = lengthcode;
            _lengthname = lengthname;
        }
        public TVC_CATEInfo(DataRow dr)
        {
            if (dr != null)
            {
                _maingroup = dr[Field.maingroup.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.maingroup.ToString()]);
                _mainname = dr[Field.mainname.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.mainname.ToString()]);
                _subgroup = dr[Field.subgroup.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.subgroup.ToString()]);
                _subname = dr[Field.subname.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.subname.ToString()]);
                _sizecode = dr[Field.sizecode.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.sizecode.ToString()]);
                _sizename = dr[Field.sizename.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.sizename.ToString()]);
                _lengthcode = dr[Field.lengthcode.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.lengthcode.ToString()]);
                _lengthname = dr[Field.lengthname.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.lengthname.ToString()]);
            }
        }
        public TVC_CATEInfo(DataRowView dr) : this(dr.Row) { }
        public TVC_CATEInfo(TVC_CATEInfo objEntr)
        {
            _maingroup = objEntr.maingroup;
            _mainname = objEntr.mainname;
            _subgroup = objEntr.subgroup;
            _subname = objEntr.subname;
            _sizecode = objEntr.sizecode;
            _sizename = objEntr.sizename;
            _lengthcode = objEntr.lengthcode;
            _lengthname = objEntr.lengthname;
        }
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("TVC_CATEPRV");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.maingroup.ToString(), typeof(String)),
				new DataColumn(Field.mainname.ToString(), typeof(String)),
				new DataColumn(Field.subgroup.ToString(), typeof(String)),
				new DataColumn(Field.subname.ToString(), typeof(String)),
				new DataColumn(Field.sizecode.ToString(), typeof(String)),
				new DataColumn(Field.sizename.ToString(), typeof(String)),
				new DataColumn(Field.lengthcode.ToString(), typeof(String)),
				new DataColumn(Field.lengthname.ToString(), typeof(String))
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.maingroup.ToString()] = _maingroup;
            row[Field.mainname.ToString()] = _mainname;
            row[Field.subgroup.ToString()] = _subgroup;
            row[Field.subname.ToString()] = _subname;
            row[Field.sizecode.ToString()] = _sizecode;
            row[Field.sizename.ToString()] = _sizename;
            row[Field.lengthcode.ToString()] = _lengthcode;
            row[Field.lengthname.ToString()] = _lengthname;
            return row;
        }
        #endregion InitTable
    }
}
